﻿using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class ServerPanel : BasePanel
{
    public Button btnSure;
    public Button btnChoose;
    public Button btnBack;

    public TMP_Text serverId;
    public TMP_Text serverName;
    public override void Init()
    {
        btnSure.onClick.AddListener(() =>
        {
            LoginManager.Instance.SaveLoginData();
            SceneManager.LoadScene("GameScene");
        });
        btnChoose.onClick.AddListener(() =>
        {
            UIManager.Instance.ShowPanel<ServerChoosePanel>();
            UIManager.Instance.HidePanel<ServerPanel>();
        });
        btnBack.onClick.AddListener(() =>
        {
            LoginManager.Instance.loginData.isAutoLogin = false;
            UIManager.Instance.ShowPanel<LoginPanel>();
            UIManager.Instance.HidePanel<ServerPanel>();
        });
        Server server = LoginManager.Instance.QueryServerById(LoginManager.Instance.loginData.serverId);
        serverId.text = server.id + "区";
        serverName.text = server.name;
    }
}
